/*
 * Sesame Inc.
 * Copyright (c) 2009 All Rights Reserved.
 */
package com.sesame.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

import com.sesame.service.AlbumService;
import com.sesame.service.ContactService;
import com.sesame.service.UserService;

/**
 * @author voidman
 * 
 */

public class DeleteAskController extends AbstractController {

    private UserService userService;

    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    protected ModelAndView handleRequestInternal(HttpServletRequest request,
            HttpServletResponse reponse) throws Exception {

        Integer askId = Integer.parseInt(request.getParameter("askId"));
        Integer adminId = (Integer) request.getSession().getAttribute("userId");

        if (adminId.intValue() == 2 || adminId.intValue() == 3) {
            userService.deleteAsk(askId);
            return new ModelAndView("redirect:" + request.getHeader("referer"));
        } else {
            return new ModelAndView("redirect:error.html");
        }
    }

}